package com.justech.eat.entity;

import com.justech.common.util.DateUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * @program: eat-service
 * @description:
 * @author: feifei.li
 * @create: 2020-05-22 08:48
 **/
@Table(name = "e_order_detail")
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class OrderDetail implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private Long orderId;

    private Integer type;

    private Integer result;

    private int status;

    private boolean isFinal;

    private Date createTime;

    private String createBy;

    private Date updateTime;

    private String updateBy;

    public OrderDetail(Long orderId, Integer type, Date createTime, String createBy) {
        this.orderId = orderId;
        this.type = type;
        this.createTime = createTime;
        this.createBy = createBy;
        this.result = 0;
        this.status = 0;
    }

    public OrderDetail(Long orderId, Integer type, int result, Date createTime, String createBy) {
        this.orderId = orderId;
        this.type = type;
        this.createTime = createTime;
        this.createBy = createBy;
        this.result = result;
        this.status = 0;
    }

    public static OrderDetail build(Long orderId, Integer type, int result) {
        OrderDetail detail = new OrderDetail(orderId, type, result, DateUtil.now(), "Automatic meal Report");
        return detail;
    }
}

